import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';
import 'package:pull_to_refresh_flutter3/pull_to_refresh_flutter3.dart';
import 'package:untitled1/app/widgets/toast/MyToast.dart';

import '../../../res/myColors.dart';
import '../../../utils/utilScreen.dart';
import '../../../widgets/TextSelector.dart';
import '../../../widgets/TitleBar.dart';
import '../../../widgets/base_page/BaseStatefulPage.dart';
import '../employer/EmployerPageListController.dart';
import 'BrokeraItemPage.dart';
import 'BrokeragePageController.dart';
import 'ContractManageItemPage.dart';

//佣金
class ContractManagePage extends BaseStatefulPage {
  @override
  BaseStatefulPageState<BaseStatefulPage> createState() {
    return _ContractManagPageState();
  }

}

class _ContractManagPageState extends BaseStatefulPageState<ContractManagePage> {
  final controllerData=Get.put(BrokeragePageController());
  @override
  void initState() {
    controllerData.page_index.value=3;
    super.initState();
  }
  @override
  Widget buildPage(BuildContext context) {

    return Scaffold(
      appBar: TitleBar(title: "合同管理"),
      body:  Container(
        width: utilScreen.getScreenWidth(context),
        height: utilScreen.getScreenHeight(context),
        decoration: BoxDecoration(
          color: Colors.white,
          // borderRadius: BorderRadius.only(
          //   topLeft: Radius.circular(5),
          //   topRight: Radius.circular(5),
          // ),
        ),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            TextSelector(
              selectedIndex: controllerData.page_index.value,
              options: ['全部', '待签署', '待我签署', '签署完成', '已作废'],
              onTap: (index) {
                print(">]index=${index}");
                WidgetsBinding.instance.addPostFrameCallback((_) {
                  controllerData.page_index.value = index;
                });
              },
            ),
            Divider(height: 1,color: myColors.c_D1D3D5,),
            Expanded(child: Obx(()=>IndexedStack(
              sizing: StackFit.expand,
              index: controllerData.page_index.value,
              children: [
                ContractManageItemPage(0,controllerData.page_index.value),
                ContractManageItemPage(1,controllerData.page_index.value),
                ContractManageItemPage(2,controllerData.page_index.value),
                ContractManageItemPage(3,controllerData.page_index.value),
                ContractManageItemPage(4,controllerData.page_index.value),
              ],
            )))
          ],
        ),
      ),
    );
  }

}

